class CommodityController:
    def __init__(self):
        self.comm_list = []

    def add_commodity(self, name):
        self.comm_list.append(name)

    def __iter__(self):
        return CommodityIter(self.comm_list)

class CommodityIter:
    def __init__(self, comm_list):
        self.comm_iter_list = comm_list
        self.index = -1

    def __next__(self):
        if self.index == len(self.comm_iter_list) - 1:
            raise StopIteration()
        self.index += 1
        return self.comm_iter_list[self.index]

comm = CommodityController()
comm.add_commodity("1")
comm.add_commodity("2")

iterator = comm.__iter__()
while True:
    try:
        item = iterator.__next__()
        print(item)
    except StopIteration:
        print('1')
        break